package org.example.generics;

public class Demo3 {
    public static void main(String[] args) {
        GenericInterfaceImplement gi1 = new GenericInterfaceImplement();
        gi1.method("666999");	// "s1:666999"
        GenericInterfaceImplement01<Integer> gi2 = new GenericInterfaceImplement01<>();
        gi2.method(2020);		// "s2:2020"
    }

    // 含有泛型的接口
    public interface GenericInterface<I> {
        // 接口的抽象方法，i 泛型参数
        public abstract void method(I i);
    }

    // 创建接口实现类1
    public static class GenericInterfaceImplement implements GenericInterface<String>{
        @Override
        public void method(String s) {
            System.out.println("s1:" + s);
        }
    }

    // 创建接口实现类2
    public static class GenericInterfaceImplement01<I> implements GenericInterface<I>{
        @Override
        public void method(I i) {
            System.out.println("s2:" + i);
        }
    }
}
